﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace FourPartHarmony2
{
    /// <summary>
    /// WindowChooseChord.xaml の相互作用ロジック
    /// </summary>
    public partial class WindowChooseChord : Window
    {
        //private Glass       glass;
        private WindowMain  m_formMusic;
        private bool        m_setupCompleted = false;
        private Music       m_music = null;
        private int         m_chordInsertPosOnMusic = 0; //< chordInsertPosOnMusicの手前に新しい和音を挿入。
        private ChordType   m_chordType;
        private List<Chord> m_chordList = null;

        public WindowChooseChord(WindowMain mainWindow, Music music, int insertPos) {
            this.m_formMusic = mainWindow;
            this.m_music = music;
            this.m_chordInsertPosOnMusic = insertPos;

            InitializeComponent();

            grandStaffControl.SetCursorPositionChangedDelegate(
                    new GrandStaffControl.CursorPositionChangedDelegate(CursorPositionChangedDelegate));

            m_setupCompleted = true;
            InitializeGui();
            RedrawChordList();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e) {
            //glass = new Glass(this, 0);
            //glass.Apply();
        }

        private void InitializeGui() {
            // GUIの初期状態
            m_chordType.musicKey = MusicKey.Cdur;
            m_chordType.keyRelation = KeyRelation.I調;
            m_chordType.chordDegree = CD.I;
            m_chordType.positionOfAChord = PositionOfAChord.密;
            m_chordType.numberOfNotes = NumberOfNotes.Triad;
            m_chordType.omission = Omission.None;
            m_chordType.bassInversion = Inversion.根音;
            m_chordType.termination = TerminationType.None;

            if (m_music.GetNumOfChords() == 0 ||
                m_chordInsertPosOnMusic < 1) {
                return;
            }

            // 主調設定
            var lastChord = m_music.GetChord(m_chordInsertPosOnMusic - 1);
            m_chordType.musicKey = lastChord.MusicKey;

            // 配分設定: 挿入位置の配分にあわせる
            m_chordType.positionOfAChord = lastChord.PositionOfAChord;

            switch (m_chordType.musicKey) {
            case MusicKey.Cdur: radioButtonCdur.IsChecked = true; break;
            case MusicKey.Ddur: radioButtonDdur.IsChecked = true; break;
            case MusicKey.Edur: radioButtonEdur.IsChecked = true; break;
            case MusicKey.Fdur: radioButtonFdur.IsChecked = true; break;
            case MusicKey.Gdur: radioButtonGdur.IsChecked = true; break;
            case MusicKey.Adur: radioButtonAdur.IsChecked = true; break;
            case MusicKey.Hdur: radioButtonHdur.IsChecked = true; break;
            case MusicKey.CISdur: radioButtonCisdur.IsChecked = true; break;
            case MusicKey.DESdur: radioButtonDesdur.IsChecked = true; break;
            case MusicKey.ESdur: radioButtonEsdur.IsChecked = true; break;
            case MusicKey.FISdur: radioButtonFisdur.IsChecked = true; break;
            case MusicKey.GESdur: radioButtonGesdur.IsChecked = true; break;
            case MusicKey.ASdur: radioButtonAsdur.IsChecked = true; break;
            case MusicKey.Bdur: radioButtonBdur.IsChecked = true; break;
            case MusicKey.Cmoll: radioButtonCmoll.IsChecked = true; break;
            case MusicKey.Dmoll: radioButtonDmoll.IsChecked = true; break;
            case MusicKey.Emoll: radioButtonEmoll.IsChecked = true; break;
            case MusicKey.Fmoll: radioButtonFmoll.IsChecked = true; break;
            case MusicKey.Gmoll: radioButtonGmoll.IsChecked = true; break;
            case MusicKey.Amoll: radioButtonAmoll.IsChecked = true; break;
            case MusicKey.Hmoll: radioButtonHmoll.IsChecked = true; break;
            case MusicKey.CISmoll: radioButtonCismoll.IsChecked = true; break;
            case MusicKey.ESmoll: radioButtonEsmoll.IsChecked = true; break;
            case MusicKey.FISmoll: radioButtonFismoll.IsChecked = true; break;
            case MusicKey.GISmoll: radioButtonGismoll.IsChecked = true; break;
            case MusicKey.ASmoll: radioButtonAsmoll.IsChecked = true; break;
            case MusicKey.Bmoll: radioButtonBmoll.IsChecked = true; break;
            default:
                System.Diagnostics.Debug.Assert(false);
                break;
            }
            // ここで内属記号を設定する。
            // radioButtonのセットの後にkeyRelationをセットしないとradioButtonのチェックイベントでI調に戻されてしまうので、
            m_chordType.keyRelation = lastChord.KeyRelation;

            switch (m_chordType.positionOfAChord) {
            case PositionOfAChord.密: radioButton密.IsChecked = true; break;
            case PositionOfAChord.開: radioButton開.IsChecked = true; break;
            case PositionOfAChord.Oct: radioButtonOct.IsChecked = true; break;
            default:
                System.Diagnostics.Debug.Assert(false);
                break;
            }

            switch (m_chordType.termination) {
            case TerminationType.None: radio非終止.IsChecked = true; break;
            case TerminationType.Perfect: radio全終止.IsChecked = true; break;
            case TerminationType.Plagal: radio変終止.IsChecked = true; break;
            case TerminationType.Deceptive: radio偽終止.IsChecked = true; break;
            case TerminationType.Half: radio半終止.IsChecked = true; break;
            default:
                System.Diagnostics.Debug.Assert(false);
                break;
            }

        }

        private void UpdateGui() {
            switch (m_chordType.chordDegree) {
            case CD.V:
            case CD.V_V:
                // 9の和音が設定可能。
                // 根音省略形体可能。
                radioButtonNinth.IsEnabled = true;
                checkBox根省.IsEnabled = true;
                break;
            default:
                if (radioButtonNinth.IsChecked == true) {
                    // V以外の和音は9の和音がない。
                    // 和音を生成しなおす。
                    radioButtonTriad.IsChecked = true;
                    m_chordType.numberOfNotes = NumberOfNotes.Triad;
                }
                if (checkBox根省.IsChecked == true) {
                    // 根音省略形体不可。
                    // 和音を生成しなおす。
                    checkBox根省.IsChecked = false;
                    m_chordType.omission = Omission.None;
                }
                radioButtonNinth.IsEnabled = false;
                checkBox根省.IsEnabled = false;
                break;
            }

            switch (m_chordType.numberOfNotes) {
            case NumberOfNotes.Triad:
                // 3和音が設定された。
                if (radioButton3転.IsChecked == true) {
                    // 3和音の低音位は第3転回位置には設定不可能。
                    // 和音を生成しなおす。
                    radioButton基.IsChecked = true;
                    m_chordType.bassInversion = Inversion.根音;
                }
                radioButton3転.IsEnabled = false;
                break;
            case NumberOfNotes.Seventh:
                // 7の和音が設定された。
                // 7の和音の低音位は第3転回位置に設定可能。
                radioButton3転.IsEnabled = true;
                break;
            case NumberOfNotes.Ninth:
                // 9の和音が設定された。
                // 9の和音の低音位は第3転回位置に設定可能。
                radioButton3転.IsEnabled = true;
                break;
            default:
                System.Diagnostics.Debug.Assert(false);
                break;
            }

            // 終止のラジオボタンが押せるか？

            radio全終止.IsEnabled = false;
            radio変終止.IsEnabled = false;
            radio偽終止.IsEnabled = false;
            radio半終止.IsEnabled = false;

            if (1 <= m_chordInsertPosOnMusic) {
                var prevChord = m_music.GetChord(m_chordInsertPosOnMusic-1);
                var prevChordType = prevChord.ChordType;

                if (m_chordType.chordDegree == CD.V) {
                    if (expander1.IsExpanded) {
                        if (m_chordType.bassInversion == Inversion.根音 &&
                            m_chordType.numberOfNotes == NumberOfNotes.Triad) {
                            radio半終止.IsEnabled = true;
                        }
                    } else {
                        radio半終止.IsEnabled = true;
                    }
                }
                if (m_chordType.chordDegree == CD.VI &&
                    prevChordType.chordDegree == CD.V &&
                    prevChordType.bassInversion == Inversion.根音 &&
                    (prevChordType.numberOfNotes == NumberOfNotes.Triad ||
                     prevChordType.numberOfNotes == NumberOfNotes.Seventh)) {
                    if (expander1.IsExpanded) {
                        if (m_chordType.bassInversion == Inversion.根音 &&
                            m_chordType.numberOfNotes == NumberOfNotes.Triad) {
                            radio偽終止.IsEnabled = true;
                        }
                    } else {
                        radio偽終止.IsEnabled = true;
                    }
                }

                if (m_chordType.chordDegree == CD.I) {
                    if (prevChordType.chordDegree == CD.V &&
                        prevChordType.bassInversion == Inversion.根音 &&
                        (prevChordType.numberOfNotes == NumberOfNotes.Triad ||
                         prevChordType.numberOfNotes == NumberOfNotes.Seventh)) {
                        if (expander1.IsExpanded) {
                            if (m_chordType.bassInversion == Inversion.根音 &&
                                m_chordType.numberOfNotes == NumberOfNotes.Triad) {
                                radio全終止.IsEnabled = true;
                            }
                        } else {
                            radio全終止.IsEnabled = true;
                        }
                    }

                    if (prevChordType.chordDegree == CD.IV &&
                        (prevChordType.bassInversion == Inversion.根音 ||
                         prevChordType.bassInversion == Inversion.第5音) &&
                        prevChordType.numberOfNotes == NumberOfNotes.Triad) {
                        if (expander1.IsExpanded) {
                            if (m_chordType.bassInversion == Inversion.根音 &&
                                m_chordType.numberOfNotes == NumberOfNotes.Triad) {
                                radio変終止.IsEnabled = true;
                            }
                        } else {
                            radio変終止.IsEnabled = true;
                        }
                    }
                }
            }

            switch (m_chordType.termination) {
            case TerminationType.Perfect: if (!radio全終止.IsEnabled) { m_chordType.termination = TerminationType.None; }; break;
            case TerminationType.Plagal: if (!radio変終止.IsEnabled) { m_chordType.termination = TerminationType.None; }; break;
            case TerminationType.Deceptive: if (!radio偽終止.IsEnabled) { m_chordType.termination = TerminationType.None; }; break;
            case TerminationType.Half: if (!radio半終止.IsEnabled) { m_chordType.termination = TerminationType.None; }; break;
            default:
                break;
            }

            switch (m_chordType.termination) {
            case TerminationType.None: radio非終止.IsChecked = true; break;
            case TerminationType.Perfect: radio全終止.IsChecked = true; break;
            case TerminationType.Plagal: radio変終止.IsChecked = true; break;
            case TerminationType.Deceptive: radio偽終止.IsChecked = true; break;
            case TerminationType.Half: radio半終止.IsChecked = true; break;
            default:
                System.Diagnostics.Debug.Assert(false);
                break;
            }

            // 準固有和音、固有VIIのチェックボックスが押せるか？
            if (m_chordType.Is内部調は長調()) {
                switch (m_chordType.chordDegree) {
                case CD.II:
                case CD.IV:
                case CD.VI:
                    checkBox準固有.IsEnabled = true;
                    break;
                case CD.V:
                case CD.V_V:
                    if (!expander1.IsExpanded) {
                        checkBox準固有.IsEnabled = true;
                        break;
                    }
                    if (m_chordType.numberOfNotes == NumberOfNotes.Ninth) {
                        checkBox準固有.IsEnabled = true;
                        break;
                    }
                    checkBox準固有.IsEnabled = false;
                    checkBox準固有.IsChecked = false;
                    break;
                default:
                    checkBox準固有.IsEnabled = false;
                    checkBox準固有.IsChecked = false;
                    break;
                }
                checkBox固有VII.IsEnabled = false;
                checkBox固有VII.IsChecked = false;
            } else {
                checkBox準固有.IsEnabled = false;
                checkBox準固有.IsChecked = false;

                switch (m_chordType.chordDegree) {
                case CD.V:
                    checkBox固有VII.IsEnabled = true;
                    break;
                default:
                    checkBox固有VII.IsEnabled = false;
                    checkBox固有VII.IsChecked = false;
                    break;
                }
            }

            // 付加和音のラジオボタンが押せるか？
            radio付加6.IsEnabled = false;
            radio付加46.IsEnabled = false;
            if (m_chordType.chordDegree == CD.IV) {
                radio付加6.IsEnabled = true;
                radio付加46.IsEnabled = true;
            }

            switch (m_chordType.addedTone) {
            case AddedToneType.Six: if (!radio付加6.IsEnabled) { m_chordType.addedTone = AddedToneType.None; } break;
            case AddedToneType.SixFour: if (!radio付加46.IsEnabled) { m_chordType.addedTone = AddedToneType.None; } break;
            default:
                break;
            }

            switch (m_chordType.addedTone) {
            case AddedToneType.None: radio付加なし.IsChecked = true; break;
            case AddedToneType.Six: radio付加6.IsChecked = true; break;
            case AddedToneType.SixFour: radio付加46.IsChecked = true; break;
            default:
                System.Diagnostics.Debug.Assert(false);
                break;
            }

            // 上変和音、下変和音のラジオが押せるか？
            // 付加和音に上変が付けられるので付加和音判定の後に上変のチェックをする。
            radioButton下変.IsEnabled = false;
            radioButton上変.IsEnabled = false;
            radioButtonドリア.IsEnabled = false;
            radioButtonナポリ.IsEnabled = false;
            if (m_chordType.chordDegree == CD.V_V) {
                radioButton下変.IsEnabled = true;
            }
            if (m_chordType.chordDegree == CD.II &&
                    (m_chordType.Is内部調は短調() || m_chordType.is準固有)) {
                radioButtonナポリ.IsEnabled = true;
            }

            if (m_chordType.chordDegree == CD.IV &&
                    m_chordType.Is内部調は短調()) {
                radioButtonドリア.IsEnabled = true;
            }
            if (m_chordType.chordDegree == CD.V ||
                    m_chordType.chordDegree == CD.V_V) {
                radioButton上変.IsEnabled = true;
            }

            if (m_chordType.chordDegree == CD.IV &&
                    (m_chordType.addedTone == AddedToneType.Six ||
                    m_chordType.addedTone == AddedToneType.SixFour)) {
                radioButton上変.IsEnabled = true;
            }

            switch (m_chordType.alteration) {
            case AlterationType.None: break;
            case AlterationType.Raised:  if (!radioButton上変.IsEnabled) { m_chordType.alteration = AlterationType.None; } break;
            case AlterationType.Lowered: if (!radioButton下変.IsEnabled) { m_chordType.alteration = AlterationType.None; } break;
            case AlterationType.Dorian:  if (!radioButtonドリア.IsEnabled) { m_chordType.alteration = AlterationType.None; } break;
            case AlterationType.Naples:  if (!radioButtonナポリ.IsEnabled) { m_chordType.alteration = AlterationType.None; } break;
            default:
                System.Diagnostics.Debug.Assert(false);
                break;
            }

            switch (m_chordType.alteration) {
            case AlterationType.None: radioButton正位.IsChecked = true; break;
            case AlterationType.Raised: radioButton上変.IsChecked = true; break;
            case AlterationType.Lowered: radioButton下変.IsChecked = true; break;
            case AlterationType.Dorian: radioButtonドリア.IsChecked = true; break;
            case AlterationType.Naples: radioButtonナポリ.IsChecked = true; break;
            default:
                System.Diagnostics.Debug.Assert(false);
                break;
            }

            // 選択状態の内属記号
            comboBox調.SelectedIndex = (int)m_chordType.keyRelation;

            // 内属記号の表示。
            UpdateComboItem内部調(comboItemI調, "I調(主調)", KeyRelation.I調);
            UpdateComboItem内部調(comboItemII調, "II調", KeyRelation.II調);
            UpdateComboItem内部調(comboItemMII調, "-II調", KeyRelation.MII調);
            UpdateComboItem内部調(comboItemIII調, "III調", KeyRelation.III調);
            UpdateComboItem内部調(comboItemIV調, "IV調", KeyRelation.IV調);
            UpdateComboItem内部調(comboItemV調, "V調", KeyRelation.V調);
            UpdateComboItem内部調(comboItemVI調, "VI調", KeyRelation.VI調);
            UpdateComboItem内部調(comboItemVII調, "VII調", KeyRelation.VII調);
            UpdateComboItem内部調(comboItemVIIU調, "VII↑調", KeyRelation.VIIU調);

            UpdateComboItem内部調(comboItemCI調, "○I調", KeyRelation.CI調);
            UpdateComboItem内部調(comboItemCMII調, "○-I調", KeyRelation.CMII調);
            UpdateComboItem内部調(comboItemCIII調, "○III調", KeyRelation.CIII調);
            UpdateComboItem内部調(comboItemCIV調, "○IV調", KeyRelation.CIV調);
            UpdateComboItem内部調(comboItemCV調, "○V調", KeyRelation.CV調);
            UpdateComboItem内部調(comboItemCVI調, "○VI調", KeyRelation.CVI調);
            UpdateComboItem内部調(comboItemCVII調, "○VII調", KeyRelation.CVII調);

            UpdateComboItem内部調(comboItemPI調, "+I調", KeyRelation.PI調);
            UpdateComboItem内部調(comboItemPII調, "+II調", KeyRelation.PII調);
            UpdateComboItem内部調(comboItemPIII調, "+III調", KeyRelation.PIII調);
            UpdateComboItem内部調(comboItemPIV調, "+IV調", KeyRelation.PIV調);
            UpdateComboItem内部調(comboItemPV調, "+V調", KeyRelation.PV調);
            UpdateComboItem内部調(comboItemPVI調, "+VI調", KeyRelation.PVI調);
            UpdateComboItem内部調(comboItemPVIIU調, "+VII↑調", KeyRelation.PVIIU調);

            UpdateComboItem内部調(comboItemPIIIp調, "+IIIp調", KeyRelation.PIIIp調);
            UpdateComboItem内部調(comboItemPVIp調, "+VIp調", KeyRelation.PVIp調);
            UpdateComboItem内部調(comboItemPVIIUp調, "+VII↑p調", KeyRelation.PVIIUp調);

            UpdateComboItem内部調(comboItemTII調, "△II調", KeyRelation.TII調);
            UpdateComboItem内部調(comboItemTIII調, "△III調", KeyRelation.TIII調);
            UpdateComboItem内部調(comboItemTVI調, "△VI調", KeyRelation.TVI調);
            UpdateComboItem内部調(comboItemTVIIU調, "△VII↑調", KeyRelation.TVIIU調);

            UpdateComboItem内部調(comboItemPTII調, "+△II調", KeyRelation.PTII調);
            UpdateComboItem内部調(comboItemPTIII調, "+△III調", KeyRelation.PTIII調);
            UpdateComboItem内部調(comboItemPTVI調, "+△VI調", KeyRelation.PTVI調);
            UpdateComboItem内部調(comboItemPTVIIU調, "+△VII↑調", KeyRelation.PTVIIU調);

            UpdateComboItem内部調(comboItemPTIIIp調, "+△IIIp調", KeyRelation.PTIIIp調);
            UpdateComboItem内部調(comboItemPTVIp調, "+△VIp調", KeyRelation.PTVIp調);
            UpdateComboItem内部調(comboItemPTVIIUp調, "+△VII↑p調", KeyRelation.PTVIIUp調);

            UpdateComboItem内部調(comboItemMMII調, "--II調", KeyRelation.MMII調);
            UpdateComboItem内部調(comboItemMIII調, "-III調", KeyRelation.MIII調);
            UpdateComboItem内部調(comboItemMVI調, "-VI調", KeyRelation.MVI調);
            UpdateComboItem内部調(comboItemMVII調, "-VII調", KeyRelation.MVII調);

            UpdateComboItem内部調(comboItemMMIIp調, "--IIp調", KeyRelation.MMIIp調);
            UpdateComboItem内部調(comboItemMIIIp調, "-IIIp調", KeyRelation.MIIIp調);
            UpdateComboItem内部調(comboItemMVIp調, "-VIp調", KeyRelation.MVIp調);
        
            UpdateComboItem内部調(comboItemMCMII調, "-○-II調", KeyRelation.MCMII調);
            UpdateComboItem内部調(comboItemMCIII調, "-○III調", KeyRelation.MCIII調);
            UpdateComboItem内部調(comboItemMCVI調, "-○VI調", KeyRelation.MCVI調);
            UpdateComboItem内部調(comboItemMCVII調, "-○VII調", KeyRelation.MCVII調);
        
            UpdateComboItem内部調(comboItemMCMIIp調, "-○-IIp調", KeyRelation.MCMIIp調);
            UpdateComboItem内部調(comboItemMCIIIp調, "-○IIIp調", KeyRelation.MCIIIp調);
            UpdateComboItem内部調(comboItemMCVIp調, "-○VIp調", KeyRelation.MCVIp調);
        }

        private void UpdateComboItem内部調(ComboBoxItem cbi, string s, KeyRelation chordKey) {
            var internalKey = new MusicKeyInfo(m_chordType.musicKey, chordKey).InternalKey;
            if (internalKey == MusicKey.Invalid) {
                cbi.Visibility = System.Windows.Visibility.Collapsed;
            } else {
                cbi.Visibility = System.Windows.Visibility.Visible;
                cbi.Content = string.Format("{0} {1}", s, internalKey);
            }
        }

        /// <summary>
        /// ChooseChordダイアログの和音一覧表を再描画する。
        /// </summary>
        private void RedrawChordList()
        {
            if (!m_setupCompleted) {
                return;
            }

            UpdateGui();

            Music.GenerateChordListType type = Music.GenerateChordListType.All;
            if (expander1.IsExpanded) {
                type = Music.GenerateChordListType.OnlySpecified;
            }
            Chord prevChord = null;
            if (1 <= m_chordInsertPosOnMusic) {
                prevChord = m_music.GetChord(m_chordInsertPosOnMusic - 1);
            }

            m_chordList = m_music.GenerateChordListAndSort(type, m_chordType, prevChord, m_chordInsertPosOnMusic);

            //panelGrandStaff.AutoScrollPosition = new Point(0, 0);

            grandStaffControl.UpdateChordList(m_chordList, true);
            if (0 == m_chordList.Count) {
                buttonPlayChord.IsEnabled = false;
            } else {
                buttonPlayChord.IsEnabled = true;
            }
        }

        public Chord GetSelectedChord()
        {
            return grandStaffControl.GetSelectedChord();
        }

        // ####################################################################################
        // ####################################################################################
        // イベントハンドラ。

        public void CursorPositionChangedDelegate(int newCursorPos, int cursorX, Chord selectedChord) {
            if (null == selectedChord) {
                textBlockVerdict.Text = string.Empty;
            } else {
                textBlockVerdict.Text = selectedChord.GetVerdictText();
            }
        }

        /*
        private void panel1_Scroll(object sender, ScrollEventArgs e) {
            grandStaffControl.Focus();
        }
        */

        private void buttonLeft_Click(object sender, RoutedEventArgs e)
        {
            grandStaffControl.ChooseLeftChord();
        }

        private void buttonRight_Click(object sender, RoutedEventArgs e)
        {
            grandStaffControl.ChooseRightChord();
        }

        private void buttonPlay_Click(object sender, RoutedEventArgs e)
        {
            Chord chord = grandStaffControl.GetSelectedChord();
            if (null == chord) {
                return;
            }

            List<Chord> playChords = new List<Chord>();
            if (1 <= m_chordInsertPosOnMusic) {
                Chord prevChord = m_music.GetChord(m_chordInsertPosOnMusic - 1);
                playChords.Add(prevChord);
            }
            playChords.Add(chord);

            MidiManager mm = Chord.ChordListToMidiFile(playChords, 60);
            mm.PlayNow();
        }

        private void buttonOK_Click(object sender, RoutedEventArgs e)
        {
            m_formMusic.InsertChordToMusic(m_chordInsertPosOnMusic, GetSelectedChord());
            ++m_chordInsertPosOnMusic;
            RedrawChordList();
        }

        private void radio3和音_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }
            m_chordType.numberOfNotes = NumberOfNotes.Triad;
            RedrawChordList();
        }

        private void radio7の和音_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }
            m_chordType.numberOfNotes = NumberOfNotes.Seventh;
            RedrawChordList();
        }

        private void radio9の和音_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }
            m_chordType.numberOfNotes = NumberOfNotes.Ninth;
            RedrawChordList();
        }

        private void radioNumber1_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.chordDegree = CD.I;
            RedrawChordList();
        }

        private void radioNumber2_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.chordDegree = CD.II;
            RedrawChordList();
        }

        private void radioNumber3_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.chordDegree = CD.III;
            RedrawChordList();
        }

        private void radioNumber4_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.chordDegree = CD.IV;
            RedrawChordList();
        }

        private void radioNumber5_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.chordDegree = CD.V;
            RedrawChordList();
        }

        private void radioNumber6_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.chordDegree = CD.VI;
            RedrawChordList();
        }

        private void radioNumber7_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.chordDegree = CD.VII;
            RedrawChordList();
        }

        private void radioNumberVV_CheckedChanged(object sender, RoutedEventArgs e) {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.chordDegree = CD.V_V;
            RedrawChordList();
        }

        private void radio密_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.positionOfAChord = PositionOfAChord.密;
            RedrawChordList();
        }

        private void radio開_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.positionOfAChord = PositionOfAChord.開;
            RedrawChordList();
        }

        private void radioOct_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.positionOfAChord = PositionOfAChord.Oct;
            RedrawChordList();
        }

        private void checkBox根省_Checked(object sender, RoutedEventArgs e)
        {
            if (false == ((CheckBox)sender).IsChecked) {
                m_chordType.omission = Omission.None;
                RedrawChordList();
            } else {
                m_chordType.omission = Omission.First;
                RedrawChordList();
            }
        }

        private void checkBox根省_Unchecked(object sender, RoutedEventArgs e) {
            if (false == ((CheckBox)sender).IsChecked) {
                m_chordType.omission = Omission.None;
                RedrawChordList();
            } else {
                m_chordType.omission = Omission.First;
                RedrawChordList();
            }
        }

        private void radio基_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.bassInversion = Inversion.根音;
            RedrawChordList();
        }

        private void radio1転_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.bassInversion = Inversion.第3音;
            RedrawChordList();
        }

        private void radio2転_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.bassInversion = Inversion.第5音;
            RedrawChordList();
        }

        private void radio3転_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.bassInversion = Inversion.第7音;
            RedrawChordList();
        }

        private void radioButtonCdur_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.Cdur;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonDdur_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.Ddur;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonEdur_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.Edur;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonFdur_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.Fdur;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonGdur_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.Gdur;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonAdur_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.Adur;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonHdur_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.Hdur;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonCISdur_CheckedChanged(object sender, RoutedEventArgs e) {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.CISdur;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonDESdur_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.DESdur;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonESdur_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.ESdur;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonFISdur_CheckedChanged(object sender, RoutedEventArgs e) {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.FISdur;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonGESdur_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.GESdur;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonASdur_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.ASdur;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonBdur_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.Bdur;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonCmoll_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.Cmoll;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonDmoll_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.Dmoll;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonEmoll_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.Emoll;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonFmoll_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.Fmoll;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonGmoll_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.Gmoll;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonAmoll_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.Amoll;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonHmoll_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.Hmoll;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonCISmoll_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.CISmoll;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonDISmoll_CheckedChanged(object sender, RoutedEventArgs e) {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.DISmoll;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }


        private void radioButtonESmoll_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.ESmoll;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonFISmoll_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.FISmoll;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonGISmoll_CheckedChanged(object sender, RoutedEventArgs e) {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.GISmoll;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonASmoll_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.ASmoll;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void radioButtonBmoll_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.musicKey = MusicKey.Bmoll;
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void checkBoxChordProperty_CheckedChanged(object sender, RoutedEventArgs e) {
            RedrawChordList();
        }

        private void expander1_Expanded(object sender, RoutedEventArgs e) {
            RedrawChordList();
        }

        private void expander1_Collapsed(object sender, RoutedEventArgs e) {
            RedrawChordList();
        }

        private void radio非終止_CheckedChanged(object sender, RoutedEventArgs e) {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.termination = TerminationType.None;
            RedrawChordList();
        }

        private void radio全終止_CheckedChanged(object sender, RoutedEventArgs e) {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.termination = TerminationType.Perfect;
            RedrawChordList();
        }

        private void radio偽終止_CheckedChanged(object sender, RoutedEventArgs e) {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.termination = TerminationType.Deceptive;
            RedrawChordList();
        }

        private void radio半終止_CheckedChanged(object sender, RoutedEventArgs e) {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.termination = TerminationType.Half;
            RedrawChordList();
        }

        private void radio変終止_CheckedChanged(object sender, RoutedEventArgs e) {
            if (false == ((RadioButton)sender).IsChecked) {
                return;
            }

            m_chordType.termination = TerminationType.Plagal;
            RedrawChordList();
        }

        private void checkBox準固有_Checked(object sender, RoutedEventArgs e) {
            m_chordType.is準固有 = true;
            RedrawChordList();
        }

        private void checkBox準固有_Unchecked(object sender, RoutedEventArgs e) {
            m_chordType.is準固有 = false;
            RedrawChordList();
        }

        private void checkBox固有VII_Checked(object sender, RoutedEventArgs e) {
            m_chordType.has固有VII = true;
            RedrawChordList();
        }

        private void checkBox固有VII_Unchecked(object sender, RoutedEventArgs e) {
            m_chordType.has固有VII = false;
            RedrawChordList();
        }

        private void radio正位_CheckedChanged(object sender, RoutedEventArgs e) {
            m_chordType.alteration = AlterationType.None;
            RedrawChordList();
        }

        private void radio上変_CheckedChanged(object sender, RoutedEventArgs e) {
            m_chordType.alteration = AlterationType.Raised;
            RedrawChordList();
        }

        private void radio下変_CheckedChanged(object sender, RoutedEventArgs e) {
            m_chordType.alteration = AlterationType.Lowered;
            RedrawChordList();
        }

        private void radioドリア_CheckedChanged(object sender, RoutedEventArgs e) {
            m_chordType.alteration = AlterationType.Dorian;
            RedrawChordList();
        }
        
        private void radioナポリ_CheckedChanged(object sender, RoutedEventArgs e) {
            m_chordType.alteration = AlterationType.Naples;
            RedrawChordList();
        }

        private void radio付加なし_CheckedChanged(object sender, RoutedEventArgs e) {
            m_chordType.addedTone = AddedToneType.None;
            RedrawChordList();
        }

        private void radio付加6_CheckedChanged(object sender, RoutedEventArgs e) {
            m_chordType.addedTone = AddedToneType.Six;
            RedrawChordList();
        }

        private void radio付加46_CheckedChanged(object sender, RoutedEventArgs e) {
            m_chordType.addedTone = AddedToneType.SixFour;
            RedrawChordList();
        }

        private void comboItemI調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.I調;
            RedrawChordList();
        }

        private void comboItemII調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.II調;
            RedrawChordList();
        }

        private void comboItemIII調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.III調;
            RedrawChordList();
        }

        private void comboItemIV調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.IV調;
            RedrawChordList();
        }

        private void comboItemV調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.V調;
            RedrawChordList();
        }

        private void comboItemVI調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.VI調;
            RedrawChordList();
        }

        private void comboItemVII調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.VII調;
            RedrawChordList();
        }

        private void comboItemCI調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.CI調;
            RedrawChordList();
        }

        private void comboItemCIII調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.CIII調;
            RedrawChordList();
        }

        private void comboItemCIV調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.CIV調;
            RedrawChordList();
        }

        private void comboItemCV調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.CV調;
            RedrawChordList();
        }

        private void comboItemCVI調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.CVI調;
            RedrawChordList();
        }

        private void comboItemCVII調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.CVII調;
            RedrawChordList();
        }

        private void comboItemPII調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.PII調;
            RedrawChordList();
        }

        private void comboItemPIII調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.PIII調;
            RedrawChordList();
        }

        private void comboItemPVI調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.PVI調;
            RedrawChordList();
        }

        private void comboItemMIII調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.MIII調;
            RedrawChordList();
        }

        private void comboItemMVI調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.MVI調;
            RedrawChordList();
        }

        private void comboItemMVII調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.MVII調;
            RedrawChordList();
        }

        private void comboItemMCIII調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.MCIII調;
            RedrawChordList();
        }

        private void comboItemMCVI調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.MCVI調;
            RedrawChordList();
        }

        private void comboItemMCVII調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.MCVII調;
            RedrawChordList();
        }

        private void comboItemTII調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.TII調;
            RedrawChordList();
        }

        private void comboItemTIII調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.TIII調;
            RedrawChordList();
        }

        private void comboItemTVI調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.TVI調;
            RedrawChordList();
        }

        private void comboItemPTII調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.PTII調;
            RedrawChordList();
        }

        private void comboItemPTIII調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.PTIII調;
            RedrawChordList();
        }

        private void comboItemPTVI調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.PTVI調;
            RedrawChordList();
        }

        private void comboItemCMII調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.CMII調;
            RedrawChordList();
        }

        private void comboItemVIIU調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.VIIU調;
            RedrawChordList();
        }

        private void comboItemPI調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.PI調;
            RedrawChordList();
        }

        private void comboItemPIV調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.PIV調;
            RedrawChordList();
        }

        private void comboItemPV調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.PV調;
            RedrawChordList();
        }

        private void comboItemPVIIU調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.PVIIU調;
            RedrawChordList();
        }

        private void comboItemPIIIp調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.PIIIp調;
            RedrawChordList();
        }

        private void comboItemPVIp調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.PVIp調;
            RedrawChordList();
        }

        private void comboItemPVIIUp調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.PVIIUp調;
            RedrawChordList();
        }

        private void comboItemTVIIU調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.TVIIU調;
            RedrawChordList();
        }

        private void comboItemPTVIIU調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.PTVIIU調;
            RedrawChordList();
        }

        private void comboItemPTIIIp調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.PTIIIp調;
            RedrawChordList();
        }

        private void comboItemPTVIp調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.PTVIp調;
            RedrawChordList();
        }

        private void comboItemPTVIIUp調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.PTVIIUp調;
            RedrawChordList();
        }

        private void comboItemMII調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.MII調;
            RedrawChordList();
        }

        private void comboItemMMIIp調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.MMIIp調;
            RedrawChordList();
        }

        private void comboItemMIIIp調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.MIIIp調;
            RedrawChordList();
        }

        private void comboItemMVIp調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.MVIp調;
            RedrawChordList();
        }

        private void comboItemMCMII調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.MCMII調;
            RedrawChordList();
        }

        private void comboItemMMII調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.MMII調;
            RedrawChordList();
        }

        private void comboItemMCMIIp調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.MCMIIp調;
            RedrawChordList();
        }

        private void comboItemMCIIIp調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.MCIIIp調;
            RedrawChordList();
        }

        private void comboItemMCVIp調_Selected(object sender, RoutedEventArgs e) {
            m_chordType.keyRelation = KeyRelation.MCVIp調;
            RedrawChordList();
        }

        private void radioButton下変_Checked(object sender, RoutedEventArgs e) {

        }


    }
}
